#include "bits/stdc++.h"
using namespace std;

int main(int argc, char* argv[]){

  int n;
  cin >> n;
  vector<int> stu(n);
  vector<int> taxi(n);
  for(int i=0; i<n; i++){
    cin >> stu[i];
  }
  for(int i=0; i<n; i++){
    cin >> taxi[i];
  }

  sort(stu.begin(), stu.end());
  sort(taxi.begin(), taxi.end());
  
  int total_sum = 1;
  int stu_id=0, taxi_id =0, last_stu_id =0, last_taxi_id =0;
  while(taxi_id < taxi.size()){
    if(taxi_id == stu_id && taxi[taxi_id] < stu[stu_id]){
      total_sum = 0;
      break;
    }
    else if(taxi[taxi_id] >= stu[stu_id]){
      stu_id++;
      if(stu_id == stu.size()){
        int stus = stu_id - last_stu_id;
        while(stus){
          total_sum = total_sum*stus;
          stus--;
        }
        break;
      }
    }
    else{
      int stus = stu_id - last_stu_id;
      total_sum = total_sum * stus;
      taxi_id++;
      last_stu_id++;
    }
  }

  cout << total_sum%100000007 <<endl;
  return 0;
}